package com.java.tutorials.jdk7.exceptioncatch;
import java.util.InputMismatchException;
import java.util.Scanner;
/**
 * Created by xuzhike on 2016/1/23.
 * http://www.java2s.com/Code/Java/JDK-7/Catchingmultipleexceptiontypestoimprovetypechecking.htm
 * Catching multiple exception types to improve type checking
 */
public class MultipleExceptionCatchingTest2 {
    public static void main(String[] args) {
        try {
            System.out.print("Enter a number: ");
            int number = new Scanner(System.in).nextInt();
            if (number < 0) {
                throw new InvalidParameter1();
            }
            System.out.println("The number is: " + number);
        } catch (InputMismatchException | InvalidParameter1 e) {
            System.out.println("Invalid input, try again");
        }
    }
}

class InvalidParameter1 extends java.lang.Exception {
    public InvalidParameter1() {
        super("Invalid Parameter");
    }
}
